﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Sunflower : MonoBehaviour
{
    private Animator animator;
    private SpriteRenderer spriteRenderer;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    private void Find()
    {
        animator = GetComponent<Animator>();
        spriteRenderer = GetComponent<SpriteRenderer>();
    }
    //创建时
    public void InitForCreate(bool inGrid)
    {
        Find();
        animator.speed = 0;
        if (inGrid)
        {
            spriteRenderer.sortingOrder = -1;
            spriteRenderer.color = new Color(1,1,1,0.6f);
        }

    }
    //安置时
    public void InitForPlace()
    {
        animator.speed = 1;
        spriteRenderer.sortingOrder = 0;
        InvokeRepeating("CreateSun", 5, 24);
    }


    public void CreateSun()
    {
        Sunlight sun = GameObject.Instantiate<GameObject>(GameManager.Instance.GameConf.Sun, transform.position, Quaternion.identity, transform).GetComponent<Sunlight>();
        sun.Jump();
    }
}
